﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using PALMS.Model.CustomQueries;
using PALMS.Utils;

namespace PALMS.Model.Transformers
{
    public class TransformerInfo
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public TransformerTypeEnum TransformerType { get; set; }
        public int TransformerTypeId  // For EF
        {
            get { return EnumUtils.IntValue(TransformerType); }
            set { TransformerType = EnumUtils.EnumValueOf<TransformerTypeEnum>(value); }
        }
        public string DataDecrypted { get; set; }
        public string DataEncrypted  // For EF
        {
            get { return DataDecrypted.Encrypt(); }
            set { DataDecrypted = value.Decrypt(); }
        }
        public int DataEncryptedChecksum { get; set; }  // For indexing in db

        public override bool Equals(object obj)
        {
            var other = obj as TransformerInfo;
            if (other == null)
                return false;
            return other.Id == Id;
        }

        public override int GetHashCode()
        {
            return Id.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("{0}({1}): \"{2}\"", TransformerType, Name, DataDecrypted);
        }
    }
}
